//
//  MXBaseNavigation.m
//  XLFQ
//
//  Created by 陈学明 on 17/10/31.
//  Copyright © 2017年 陈学明. All rights reserved.
//

#import "MXBaseNavigation.h"

@interface MXBaseNavigation ()<UIGestureRecognizerDelegate>

@end

@implementation MXBaseNavigation

- (void)viewDidLoad {
    [super viewDidLoad];
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.navigationBar.translucent = NO;
    self.interactivePopGestureRecognizer.delegate = self;
}
- (void)pushViewController:(UIViewController *)viewController
                  animated:(BOOL)animated {
    if (self.childViewControllers.count==1) {
        viewController.hidesBottomBarWhenPushed = YES;
        [super pushViewController:viewController
                         animated:animated];
    }else {
        [super pushViewController:viewController
                         animated:animated];
    }
}
- (UIViewController *)popViewControllerAnimated:(BOOL)animated {
    UIViewController *vc = [super popViewControllerAnimated:animated];
    if (self.childViewControllers.count == 2) {
        [(UIViewController *)self.childViewControllers.lastObject setHidesBottomBarWhenPushed:YES];
    }
    return vc;
}
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    return self.childViewControllers.count > 1;
}
@end
